package com.mxpio.erp.common.quality.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.jpa.policy.impl.CreatedDatePolicy;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "V_MB_ERP_INSPECTION_BILL_PASS_RATE")
@Schema(description="一次检验单合格率")
public class VEInspectionBillPassRate implements DictAble, Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Schema(description = "申请时间（年月）")
    @Column(name = "YEAR_MONTH_")
    private String yearMonth;

    @Generator(policy = CreatedDatePolicy.class)
    @Column(name = "CREATE_TIME", updatable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "创建时间")
    private Date createTime;

    @Column(name = "TYPE_")
    @Schema(description = "类型")
    private String type;


    @Column(name = "QUANTITY_")
    @Schema(description = "报检数量")//验收单确认数量
    private BigDecimal quantity;

    @Column(name = "RECEIVE_QUANTITY_")
    @Schema(description = "合格数量")//接收数量通过汇总计算
    private BigDecimal receiveQuantity;

    @Column(name = "PASS_RATE_")
    @Schema(description = "合格率")
    private BigDecimal passRate;

    @Transient
    private Map<String, String> textMap;
    public String putText(String key, String value) {
        if (textMap == null) {
            textMap = new HashMap<>();
        }
        return textMap.put(key, value);
    }
}
